
#include "member_BAudioOutput.h"

using namespace BWE;

member_BAudioOutput::member_BAudioOutput(BAudioOutput* audioOutput)
{
	boss = audioOutput;
	format = Format_UChar;
	channelCount = 2;
	sampleRate = 22050;
	dirtyFormat = true;
	state = BAudio::State_None;
#ifdef linux
	dsp_fd = 0;
	file_fd = 0;
#endif
#ifdef _WIN32
	hWaveOut = 0;
#endif
}
member_BAudioOutput::~member_BAudioOutput()
{

}

bool member_BAudioOutput::initFormat()
{
	if (!dirtyFormat)
		return true;
	dirtyFormat = false;
	fmtlen = 0;
	switch (format)
	{
	case Format_Char:
	case Format_UChar:
		fmtlen = 1;
		break;
	case Format_Short:
	case Format_UShort:
		fmtlen = 2;
		break;
	case Format_Int:
	case Format_UInt:
		fmtlen = 4;
		break;
	default:
		return false;
	}
#ifdef _WIN32
	wavform.wFormatTag = WAVE_FORMAT_PCM;
	wavform.nChannels = channelCount;
	wavform.nSamplesPerSec = sampleRate;
	wavform.nAvgBytesPerSec = sampleRate * channelCount * fmtlen;
	wavform.nBlockAlign = channelCount * fmtlen;
	wavform.wBitsPerSample = fmtlen * 8;
	wavform.cbSize = 0;
#endif
	return true;
}

void member_BAudioOutput::emitSignals()
{

}
